#include "..\direct3d\cdirect3d.h"
#include "..\import\cimport.h"
#include "..\win32\cwinengine.h"

namespace NEngine {

// ================================================================================================
// Basic graphics engine 
// ================================================================================================
class CEngine {

private:

    CDirect3D direct3d;                 // -- direct3d 
    CImportObject importer;  	    	// -- imports mesh data from a text file
    CImportLights limporter;            // -- imports lights data in the scene
    CBuildLights lightbuilder;          // -- builds the lights
    CCamera* curcam;                    // -- all the cameras in the scene
    CDynamicArray<CCamera> cams;        // -- all the views in the scene
    CDynamicArray<CCamera*> lviews;     // -- all the light views in the scene
    CCameraInputHandler ilistener; 		// -- handles input
    CWindow window;                		// -- handles windows related stuff
    uint width;                    		// -- width of the viewport
    uint height;                   		// -- height of the viewport
    bool d3dinit;                  		// -- flag for d3d being initialized
    bool wininit;                  		// -- flag for window being initialized
    bool listinit;                 		// -- flag for if the listener has been intitialized
    bool kill;                     		// -- flag to see if it is time for the engine to die

    // -- listen for input
    void Listen();

    // -- update the scene
    void Update();

    // -- render the scene
    void Render();

    // -- scan for resources in the resources directory
    bool LoadResources();

    // -- create cameras
    void CreateInitialCamera();

public:
    
    // -- constructor
    CEngine(HINSTANCE inst, int intcmdshow, uint width, uint height);

    // -- initialize the engine
    void Init(bool wireframe);

    // -- run the engine
    MSG Run();
};

// ================================================================================================
// Constructor
// ================================================================================================
inline CEngine::CEngine(HINSTANCE inst, int intcmdshow,
                        uint width_, uint height_) : window(inst, intcmdshow), width(width_), 
                                                     height(height_), kill(false) {
}

} // namespace NEngine
